home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
DELPHI32
/
SYS_TOOL
/
MULTI020
/
MULTI020.ZIP
/
DUAL.PAS
next >
Wrap
Pascal/Delphi Source File
|
1993-09-05
|
2KB
|
86 lines
unit Dual;
{ Unit which writes to the monochrome monitor (for debugging purposes).
While Write(...) and WriteLn(...) write to your color screen,
Write(dual.t,...) and WriteLn(dual.t,...) write to the monochrome
screen, #8,#9,#10 and #13 are interpreted correctly.
If there is no monochrome screen, your requests will be ignored.
Read and ReadLn are not supported.
The IDE or a debugger may get distorted by Dual. }
interface
uses dos;
var
t : text; { This is the text variable which outputs to the monochrome
monitor }
implementation
const
w : word = 0;
procedure WriteTTY(ch : char);
begin
case ch of
#13: w := w div 80 * 80;
#10: if w < 24*80 then
inc(w,80)
else begin
move(mem[segB000:160],mem[segB000:0],24*160);
asm
mov es,[segB000]
mov di,24*160
mov cx,160
mov ax,$720
cld
rep stosw
end;
end;
#8: if w mod 80 > 0 then dec(w);
#9: w := w and $FFF8+8;
else begin
mem[segB000:w*2] := byte(ch);
mem[segB000:w*2+1] := 7;
inc(w); if w = 2000 then begin
dec(w,80);
writetty(#10)
end
end;
end
end;
{$F+}
function NewOut(var f : TextRec) : Integer;
var i : Word;
Begin
if w = $FFFF then exit;
With F do
if Bufpos > 0 then
for i := 0 to BufPos-1 do
WriteTTY(BufPtr^[i]);
F.Bufpos := 0; NewOut := 0;
port[$3B4] := 14; port[$3B5] := hi(w);
port[$3B4] := 15; port[$3B5] := lo(w)
End;
{$F-}
procedure AssignCRT(var f : text);
begin
with TextRec(f) do begin
InOutFunc := @NewOut;
FlushFunc := @NewOut
end
end;
begin
port[$3B4] := 14; w := word(port[$3B5]) shl 8;
port[$3B4] := 15; w := w + port[$3B5];
port[$3B5] := 77; if port[$3B5] <> 77 then w := $FFFF;
port[$3B5] := 99; if port[$3B5] <> 99 then w := $FFFF;
port[$3B5] := w and $FF;
assign(t,''); rewrite(t);
AssignCRT(t)
end.